import 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';

//* 调用后台接口的工具类， 返回gql执行命令字符串
class DistrictApi {
  //获取全部地区信息
  static String queryAllDistricts() {
    return r"""
      query {
          allDistricts  {
          name
          packagingFactor
          deliveryFactor
          id
          addresses
         }
        }
""";
  }

  //根据id获取地区信息
  static String getDistrictById(String id) {
    return """
        query {
          district (id:"$id") {
            addresses
            packagingFactor
            deliveryFactor
            name
            id
          }
        }
        """;
  }

  //更新
  static String update(Map map) {
    return """
        mutation {
          updateDistrict(district:$map) {
            id
          }
        }
        """;
  }

  //新增
  static String create(Map map) {
    return """
        mutation {
          createDistrict(district:$map) {
            id
          }
        }
        """;
  }

  //删除
  static String delete(String id) {
    return """
        mutation {
          deleteDistrict(id:"$id")
        }
        """;
  }

}
